<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function arr(cost) {
      cost.sort((a, b) => b - a); //从大到小
      let res = 0, step = 1;

      for (let i = 0; i < cost.length; i++) {
        if (i == step * 3 - 1) {
          step++;
          continue;
        } else {
          res += cost[i]; //把值加起来
        }
      }
      return res;
    };
    console.log(arr([1, 2, 3]));
  </script>
</body>

</html>